import logging
import yagmail
import requests
import json  #数据驱动json
import yaml  #数据驱动yaml
class TestWdmoive():
    uid =None
    sid = None
    def setup_method(self):
        print("初始化用例并执行")
    def teardown_method(self):
        print("用例执行结束....")



    #json数据驱动
    def data_json(self):
        with open("log.txt","r",encoding="utf8")as e:
            return json.load(e)
    #yaml数据驱动
    def data_yaml(self):
        with open("log.txt","r",encoding="utf8")as f:
            return yaml.safe_load(f)
    #登录接口
    def test_dl(self):
        url="http://10.59.9.18/movieApi/user/v2/login"
        data={"email":"1478997572@qq.com","pwd":"eWLPHopE945d2ivttHaQTQ=="}
        r= requests.post(url=url,data=data)
        print(r.json())
        logging.info(r.json())

        assert "你的益达" in r.text
        assert  r.status_code==200

        TestWdmoive.uid = r.json()['result']['userId']
        TestWdmoive.sid = r.json()['result']['sessionId']

    #查看附近影院
    def test_findNearbyCinemas(self):
        url="http://10.59.9.18/movieApi/cinema/v1/findNearbyCinemas?longitude=116&latitude=40&page=1&count=8"
        tou = {"userId":str(TestWdmoive.uid),"sessionId":TestWdmoive.sid}
        r=requests.get(url=url,headers=tou)
        print(r.json())

    #查看电影列表
    def test_findReleaseMovieList(self):
        url="http://10.59.9.18/movieApi/movie/v2/findReleaseMovieList?page=1&count=10"
        tou = {"userId":str(TestWdmoive.uid),"sessionId":TestWdmoive.sid}
        r=requests.get(url=url,headers=tou)
        print(r.json())
    # 根据电影ID和影院ID查询电影排期列表
    def test_findMovieSchedule(self):
        try:
            url="http://10.59.9.18/movieApi/movie/v2/findMovieSchedule?movieId=16&cinemaId=11"
            tou = {"userId":str(TestWdmoive.uid),"sessionId":TestWdmoive.sid}
            r=requests.get(url=url,headers=tou)
            print(r.json())
            logging.info(r.json)
        except Exception as e:  #e变量存放异常信息
            logging.info("出错了！")
            logging.info(e)



    # 购票下单
    #支付